package com.tanhua.autoconfig;

import com.tanhua.autoconfig.properties.*;
import com.tanhua.autoconfig.template.*;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @Description: test
 * @Create by: JJ菜菜
 * @Date: 2021/11/25 23:13
 */

// 将属性从文件中读取出来
@EnableConfigurationProperties({
        SmsProperties.class,
        OssProperties.class,
        ApiFaceProperties.class,
        HuanXinProperties.class,
        GreenProperties.class
})
public class TanhuaAutoConfiguration {

    // 将sms注入到spring容器中,使用有参构造
    @Bean
   public SmsTemplate smsTemplate(SmsProperties smsProperties){
       return new SmsTemplate(smsProperties);
   }

   // 将oss注入到spring容器中
   @Bean
    public OssTemplate ossTemplate(OssProperties ossProperties){
        return new OssTemplate(ossProperties);
   }

   // apiFace人脸检测
   @Bean
    public ApiFaceTemplate apiFaceTemplate(ApiFaceProperties apiFaceProperties){
        return new ApiFaceTemplate(apiFaceProperties);
   }

   // 环信
   @Bean
    public HuanXinTemplate huanXinTemplate(HuanXinProperties huanXinProperties){
        return new HuanXinTemplate(huanXinProperties);
   }

   // 阿里云内容审核
    @Bean
//    @ConditionalOnProperty(prefix = "tanhua.green",value = "enable", havingValue = "true")
    public AliyunGreenTemplate aliyunGreenTemplate(GreenProperties properties) {
        return new AliyunGreenTemplate(properties);
    }

}
